package pubmeddown;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.DSFactory;
import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelWriter;
import lombok.SneakyThrows;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 葛成瑞
 * @Date: 2025/7/30 14:16
 */
public class ExportExcel {

    @SneakyThrows
    public static void main(String[] args) {
        Db use = Db.use(DSFactory.get("dtm"));
        List<Entity> list = use.query("select * from cnki_detail");
        List<TXTs> txts = new ArrayList<>();
        for (Entity entity : list) {
            TXTs txt = new TXTs();
            txt.setSummary(entity.getStr("ab"));
            txt.setTime(entity.getStr("year"));
            txts.add(txt);
        }


        ExcelWriter writer = new BigExcelWriter("C:\\Users\\55419\\PycharmProjects\\pythonProject\\Text_Summary.xlsx");
        writer.write(txts);
        writer.close();
        System.out.println("导出成功");


    }
}
